package com.dlc.shop.distribution.api.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dlc.shop.common.config.Constant;
import com.dlc.shop.common.response.ServerResponseEntity;
import com.dlc.shop.common.util.PageParam;
import com.dlc.shop.distribution.common.dto.BindUserInfoDto;
import com.dlc.shop.distribution.common.service.DistributionBindUserService;
import com.dlc.shop.security.api.util.SecurityUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @author yami
 */
@RestController
@RequestMapping("/p/distribution")
@Tag(name = "分销员绑定用户")
@Slf4j
@AllArgsConstructor
public class DistributionBindUserController {

    private final DistributionBindUserService distributionBindUserService;

    @PostMapping("/bindUser")
    @Operation(summary = "绑定用户" , description = "根据分销员卡号绑定用户")
    @Parameters({
            @Parameter(name = "cardNo", description = "卡号" , required = true)
    })
    public ServerResponseEntity<Void> bindUser(@RequestBody String cardNo) {
        return ServerResponseEntity.success();
    }


    @GetMapping("/bindUserList")
    @Operation(summary = "绑定用户列表" , description = "获取分销员所绑定的用户列表")
    public ServerResponseEntity<IPage<BindUserInfoDto>> bindUserList(PageParam pageParam) {
        Long shopId = Constant.PLATFORM_SHOP_ID;
        String userId = SecurityUtils.getUser().getUserId();
        return ServerResponseEntity.success(distributionBindUserService.bindUserList(pageParam,shopId,userId));
    }
}
